package com.currency.mall.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.currency.mall.R;
import com.currency.mall.entity.SecurityBean;
import com.currency.mall.util.Util;

import org.w3c.dom.Text;

import java.util.List;

/**
 * Created by Administrator on 2018/12/5.
 */

public class ShareIndexAdapter extends BaseQuickAdapter<SecurityBean.SecurityInfo, BaseViewHolder> {

    public ShareIndexAdapter(@Nullable List<SecurityBean.SecurityInfo> data, Context context) {
        super(R.layout.item_share_indexl, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, SecurityBean.SecurityInfo securityInfo) {
        TextView upsDownsVal = helper.getView(R.id.tv_upsDownsVal);
        TextView upsDownsRate = helper.getView(R.id.tv_upsDownsRate);
        TextView currentVal = helper.getView(R.id.tv_optional_price);
        currentVal.setText(Util.formatTosepara(Double.parseDouble(securityInfo.getCurrentVal())));
        if(securityInfo.getUpsDownsVal()>= 0){
            upsDownsVal.setTextColor(Color.parseColor("#E51C23"));
            currentVal.setTextColor(Color.parseColor("#E51C23"));
        }else{
            upsDownsVal.setTextColor(Color.parseColor("#259B24"));
            currentVal.setTextColor(Color.parseColor("#259B24"));
        }
        upsDownsVal.setText(securityInfo.getUpsDownsVal()+"");

        if(securityInfo.getUpsDownsRate()>= 0){
            upsDownsRate.setTextColor(Color.parseColor("#E51C23"));
        }else{
            upsDownsRate.setTextColor(Color.parseColor("#259B24"));
        }

        upsDownsRate.setText(securityInfo.getUpsDownsRate()+"%");
        helper.setText(R.id.tv_optional_name,securityInfo.getName());

    }

}
